home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1909 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: lr46pstn.lr.tudelft.nl!koen
  2. From: koen@lr46pstn.lr.tudelft.nl (Koen D'Hondt)
  3. Newsgroups: comp.lang.c
  4. Subject: [Q] Can I do a backtrace of the current execution frame?
  5. Date: 17 Jan 1996 19:19:16 GMT
  6. Organization: Ripley Software Development
  7. Sender: koen@dutlhs1.lr.tudelft.nl
  8. Message-ID: <4dji3k$fs1@mo6.rc.tudelft.nl>
  9. NNTP-Posting-Host: lr46pstn.lr.tudelft.nl
  10.  
  11. Hi,
  12.  
  13. This is a question for you c-gurus out there. 
  14.  
  15. I'm writing a program and wish to include support for run-time
  16. debugging. I have several reasons why I want to do this. 
  17. One reason is that the program in question forks itself after initialisation, 
  18. making it not all to pleasing to debug with gdb. Another reason is that
  19. most errors occur when the program is already running for some time,
  20. so I lose quite some time in the debugger before the error occurs.
  21. I know that debugging can be a painstaking activity, so I want to ease that.
  22.  
  23. What I have so far is the following:
  24.  
  25. I've installed a number of signal handlers to catch (amongst others)
  26. SIGSEGV, SIGILL and SIGBUS. Each of these handlers call a routine 
  27. displaying what routine triggered the signal (ie: one level up)
  28.  
  29. What I actually want to show is a summary of how my program got where it
  30. is, starting with the executing frame and all the way up the stack.
  31.  
  32. One solution is to store the name of each routine in a static array when
  33. it is called, and remove it when the routine exits, but this gives a lot
  34. of overhead since there are many routines involved and (possible) critical
  35. routines get called many times. Besides, I want to include this runtime
  36. feature in the final release version also, so it better be fast. 
  37.  
  38. So my question is: can a program access it's own execution frames, and 
  39. if so, how do I do it?
  40. [I've looked in the c-faq, but I found nothing of this kind]
  41.  
  42. If it is any of your aid, I'm doing development on Linux, HP-UX and IRIX.
  43. The language used is (of course) c.
  44. Compilers I use are gcc on Linux and the native compilers on HP-UX and IRIX.
  45. X is not involved, neither is msdos/windows.
  46.  
  47. Greets,
  48. Koen D'Hondt.
  49.  
  50. PS: if you reply by email, send it to koen@dutlhs1.lr.tudelft.nl
  51. -- 
  52. Koen D'Hondt                                                   Niels Hilbrink
  53. koen@dutlhs1.lr.tudelft.nl                        niels@dutlcc3.lr.tudelft.nl
  54.  
  55. Ripley Software Development  finger niels@dutlcc3.lr.tudelft.nl for more info.
  56.